package com.uppfind.framework.dao.api.common;

import java.util.*;

/**
 * SQL参数对象
 */
public class Param implements Cloneable {

    /**
     * 条件
     */
    protected List<Term> terms = new LinkedList<>();
    /**
     * 指定要处理的字段
     */
    protected Set<String> includes = new LinkedHashSet<>();
    /**
     * 指定不处理的字段
     */
    protected Set<String> excludes = new LinkedHashSet<>();
    /**
     * 排序字段
     * @since 1.0
     */
    private List<Sort> sorts = new LinkedList<>();

    public <T extends Param> T includes(String... fields) {
        includes.addAll(Arrays.asList(fields));
        return (T) this;
    }

    public <T extends Param> T excludes(String... fields) {
        excludes.addAll(Arrays.asList(fields));
        includes.removeAll(Arrays.asList(fields));
        return (T) this;
    }

    public List<Term> getTerms() {
        return terms;
    }

    public void setTerms(List<Term> terms) {
        this.terms = terms;
    }

    public List<Sort> getSorts() {
        return sorts;
    }

    public void setSorts(List<Sort> sorts) {
        this.sorts = sorts;
    }

    public Set<String> getIncludes() {
        return includes;
    }

    public void setIncludes(Set<String> includes) {
        this.includes = includes;
    }

    public Set<String> getExcludes() {
        return excludes;
    }

    public void setExcludes(Set<String> excludes) {
        this.excludes = excludes;
    }
}
